﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using codefile;

namespace ArleneBarandGrill
{
    public partial class Form1 : Form
    {
        public DataTable DTbl = new DataTable();

        Data ms = new Data();


        public Form1()
        {
            InitializeComponent();
            exitToolStripMenuItem.Click += new EventHandler(exitToolStripMenuItem_Click);
            MenuLogin.Click += new EventHandler(MenuLogin_Click);
            AddProduct.Click += new EventHandler(AddProduct_Click);
            Adduser.Click += new EventHandler(Adduser_Click);
            ViewProduct.Click += new EventHandler(ViewProduct_Click);
            ViewUser.Click += new EventHandler(ViewUser_Click);
            mstripupdate.Click += new EventHandler(mstripupdate_Click);

        }

        void mstripupdate_Click(object sender, EventArgs e)
        {
            Form5 frm5 = new Form5();
            frm5.ShowDialog();
            
        }

        void ViewUser_Click(object sender, EventArgs e)
        {
            ms.connect();
            ms.querry("SELECT * FROM tblusers");
            DTbl = ms.DTbl;
            grid.DataSource = DTbl;
            ms.close();
        }

        void ViewProduct_Click(object sender, EventArgs e)
        {
            ms.connect();
            ms.querry("SELECT * FROM tblproducts");
            DTbl = ms.DTbl;
            grid.DataSource = DTbl;
            ms.close();
        }

        void Adduser_Click(object sender, EventArgs e)
        {
            Form3 adduser = new Form3();
            adduser.ShowDialog();
        }

        void AddProduct_Click(object sender, EventArgs e)
        {
            Form2 addpro = new Form2();
            addpro.ShowDialog();
        }

        void MenuLogin_Click(object sender, EventArgs e)
        {
            Form4 frmlog = new Form4();
            frmlog.ShowDialog();
        }

        void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        public void manipulation(string pos)
        {
            switch (pos)
            {
                case "Admin":
                    ViewProduct.Enabled = true;
                    Adduser.Enabled = true;
                    AddProduct.Enabled = true;
                    ViewUser.Enabled = true;
                    mstripupdate.Enabled = true;
                    break;

                case "Guest":
                    ViewProduct.Enabled = true;
                    mstripupdate.Enabled = false;
                    Adduser.Enabled = false;
                    AddProduct.Enabled = false;
                    ViewUser.Enabled = false;
                    break;

                case "Inventory Staff":
                    ViewProduct.Enabled = true;
                    mstripupdate.Enabled = true;
                    Adduser.Enabled = false;
                    AddProduct.Enabled = false;
                    ViewUser.Enabled = true;
                    break;
            }
        }
    }
}